package com.J1ay.carsys.dao;

import com.J1ay.carsys.pojo.Car;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Author J1ay
 * @Date 2021/6/2 22:18
 * @Description
 */

public interface CarMapper {
    /**
     * @Author J1ay
     * @Date 2021/6/2 22:37
     * @param
     * @Description 获取所有车辆信息
     * @return
     */
    @Select("select * from car")
    Car[] getCarList();

    /**
     * @Author J1ay
     * @Date 2021/6/2 22:40
     * @param id,num
     * @Description 根据车名、车牌号查找车辆
     * @return
     */
    @Select("select * from car where ((id is not null and id = #{id}) or (num is not null and num = #{num}))")
    Car getCarById(@Param("id") int id, @Param("num") String num);

    /**
     * @Author J1ay
     * @Date 2021/6/2 22:44
     * @param car
     * @Description 更新车辆信息
     * @return
     */

    void updateCar(@Param("car") Car car);

    /**
     * @Author J1ay
     * @Date 2021/6/2 22:44
     * @param id,num
     * @Description 根据车辆编号或车牌号删除
     * @return
     */
    @Delete("DELETE FROM car WHERE ((id is not null and id = #{id}) or (num is not null and num = #{num}))")
    int deleteCar(@Param("id") int id, @Param("num") String num);

    /**
     * @Author J1ay
     * @Date 2021/6/2 22:48
     * @param car
     * @Description 增加车辆信息
     * @return
     */
    void addCar(@Param("car") Car car);

    /**
     * @Author J1ay
     * @Date 2021/6/3 23:06
     * @param
     * @Description 筛选未出借的车辆信息
     * @return
     */
    @Select("select * from car where (status = 'no')")
    Car[] getUnBowCar();
}
